package com.zhss.designpattern.proxy;

/**
 * @author fanwei
 * @desc 代理模式 好处：（1）懒加载 （2）远程调用
 *
 */
public class ProxyPatternDemo {

    public static void main(String[] args) {
        Subject subject = new ConcreateSubject();
        Subject proxy = new Proxy(subject);
        proxy.request();

    }

    public interface Subject{
        void request();
    }

    public static class ConcreateSubject implements Subject{

        public void request() {
            System.out.println("执行真正的请求！！！！");
        }
    }

    public static class Proxy implements Subject{

        private Subject subject;

        public Proxy(Subject subject) {
            this.subject = subject;
        }

        public void request() {
            subject.request();
        }
    }
}
